/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import Model.Commande;
import Model.LigneCommande;
import Model.LigneCommandePK;
import Model.Produit;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

/**
 *
 * @author Anthares
 */
public class LigneCommandeManager extends BaseManager{

    public LigneCommandeManager(SessionFactory factory, String locale) {
        super(factory, locale);
    }
    
    public void createAndInsertLigneCommande(Commande com, Produit prod, int quantity, double reducedPrice){
        Session sess = factory.openSession();
        sess.beginTransaction();
        LigneCommande ligne = new LigneCommande(new LigneCommandePK(com.getComId(), prod.getProdId()), quantity);
        ligne.setPrixReduit(reducedPrice);
        sess.save(ligne);
        sess.getTransaction().commit();
        sess.close();
        
    }
}
